<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      var toolTipFactory = (function () {
        var toolTipList = [];

        return {
          create: function () {
            if (toolTipList.length === 0) {
              var div = document.createElement("div");
              document.body.appendChild(div);
              return div;
            } else {
                console.log("取出：",toolTipList);
              return toolTipList.shift();
            }
          },
          recover: function (toolTip) {
            toolTipList.push(toolTip);
          },
        };
      })();

      var ary = [];
      // 第一次搜索
      for (var i = 0, str; (str = ["A", "B"][i++]); ) {
        var toolTip = toolTipFactory.create();
        toolTip.innerHTML = str;
        ary.push(toolTip);
      }
      // 存储上一个搜索
      for ( var i = 0, toolTip; toolTip = ary[ i++ ]; ){
          toolTipFactory.recover( toolTip );
      };
      // 重新搜索
      for ( var i = 0, str; str = [ 'A', 'B', 'C', 'D', 'E', 'F' ][ i++ ]; ){
          var toolTip = toolTipFactory.create();
          toolTip.innerHTML = str;
      };
    </script>
  </body>
</html>
